<%@ page import="org.internna.iwebjtracker.issue.model.Issue" %>
<%@ page import="org.internna.iwebjtracker.spring.mvc.IssueController" %>
<%@ taglib prefix="iwebmvc" uri="http://tags.iwebmvc.com" %>
<%@ taglib prefix="iwebjtracker" tagdir="/WEB-INF/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<c-rt:set var="sessionUser" value="<%= org.internna.iwebmvc.security.UserManager.SESSION_USER %>" />
<c-rt:set var="issue" value="<%= IssueController.ISSUE %>" />
<c-rt:set var="issueVotes" value="<%= IssueController.ISSUE_VOTES %>" />
<c-rt:set var="issueClosed" value="<%= IssueController.ISSUE_CLOSED %>" />
<c-rt:set var="isDeveloper" value="<%= IssueController.ISSUE_DEVELOPER %>" />
<c-rt:set var="isAdministrator" value="<%= IssueController.ISSUE_ADMINISTRATOR %>" />
<c-rt:set var="userClass" value="<%= org.internna.iwebjtracker.model.TrackerUser.class %>" />
<c-rt:set var="issueClass" value="<%= org.internna.iwebjtracker.model.DefaultIssue.class %>" />
<c-rt:set var="canRequestAssignation" value="<%= IssueController.CAN_REQUEST_WORK_OWNERSHIP %>" />
<c:if test="${not requestScope[issue].parentProject.closed}">
    <iwebmvc:hide requiredRoles="ROLE_USER">
        <iwebmvc:panel title="ui.issue.actions.user" width="98%;margin:0">
            <iwebmvc:button buttonId="${requestScope[issue].alias}Comment" label="ui.issue.actions.user.comment" buttonIcon="/resource.iwebmvc?file=/images/common/postcomment_${sessionScope[sessionUser].theme}.png" buttonCssStyle="width:125px" disabled="${requestScope[issueClosed]}">
                openPopup("newcommentform");
                byId("commentParentComment").value = "";
                dijit.byId("newCommentTextarea").setValue("");
                byId("commentParentIssue").value = "${param.issue}";
                dojo.html.set(byId("commentValidationWarningContainer"), "");
                byId("commentParentIssueAlias").value = "${requestScope[issue].alias}";
            </iwebmvc:button>
            <iwebmvc:button buttonId="${requestScope[issue].alias}Attachment" label="ui.issue.actions.user.attachment" buttonIcon="/resource.iwebmvc?file=/images/common/attachment_${sessionScope[sessionUser].theme}.gif" buttonCssStyle="width:125px" disabled="${requestScope[issueClosed]}">
                dojo.publish(EDITION_MODE, [true]);
                openPopup("newattachmentform");
                byId("attachmentParentIssue").value = "${param.issue}";
                byId("attachmentParentIssueAlias").value = "${fn:replace(requestScope[issue].alias, "-", "_")}";
            </iwebmvc:button>
            <iwebmvc:button buttonId="${requestScope[issue].alias}Vote" label="ui.issue.actions.user.vote" buttonIcon="/resource.iwebmvc?file=/images/common/vote_${sessionScope[sessionUser].theme}.gif" buttonCssStyle="width:125px" disabled="${requestScope[issueClosed]}">
                voteIssue("${iwebmvc:inferDWRConvertedJavascriptClass(issueClass)}", "${param.issue}", "${requestScope[issue].alias}", ${requestScope[issueVotes]});
            </iwebmvc:button>
            <iwebmvc:button buttonId="${requestScope[issue].alias}Watch" label="ui.issue.actions.user.watch" buttonIcon="/resource.iwebmvc?file=/images/common/watcher_${sessionScope[sessionUser].theme}.gif" buttonCssStyle="width:125px" disabled="${requestScope[issueClosed]}">
                watchIssue("${iwebmvc:inferDWRConvertedJavascriptClass(issueClass)}", "${param.issue}", "${requestScope[issue].alias}", ${requestScope[issueVotes]});
            </iwebmvc:button>
        </iwebmvc:panel>
        <div class="panelSeparator"></div>
    </iwebmvc:hide>
    <c:if test="${requestScope[isDeveloper]}">
        <iwebmvc:panel title="ui.issue.actions.developer" width="98%;margin:0">
            <div>
                <span id="${requestScope[issue].alias}AssignLoading" style="display:none"><img src='<c:url value="resource.iwebmvc?file=images/loading.gif" />' alt='' /></span>
                <iwebmvc:button buttonId="${requestScope[issue].alias}Assign" label="ui.issue.actions.developer.assignme" buttonIcon="/resource.iwebmvc?file=/images/common/assigned_${sessionScope[sessionUser].theme}.gif" buttonCssStyle="width:125px" disabled="${(not requestScope[canRequestAssignation]) || (requestScope[issueClosed])}">
                    assignIssueToMe("${iwebmvc:inferDWRConvertedJavascriptClass(issueClass)}", "${requestScope[issue].alias}", "${param.issue}", "<c:url value="/resource.iwebmvc?file=/images/common/assigned_${sessionScope[sessionUser].theme}.gif" />");
                </iwebmvc:button>
            </div>
            <iwebmvc:button buttonId="${requestScope[issue].alias}Link" label="ui.issue.actions.developer.link" buttonIcon="/resource.iwebmvc?file=/images/common/link_${sessionScope[sessionUser].theme}.gif" buttonCssStyle="width:125px" disabled="${requestScope[issueClosed]}">
                cleanAndOpenLinkIssueForm("${iwebmvc:inferDWRConvertedJavascriptClass(issueClass)}", "${param.issue}", "<iwebmvc:value entity="${requestScope[issue].parentProject}" path="id" encrypt="true" />", "${requestScope[issue].alias}");
            </iwebmvc:button>
            <iwebmvc:button buttonId="${requestScope[issue].alias}Resolve" label="ui.issue.actions.developer.close" buttonIcon="/resource.iwebmvc?file=/images/common/resolve_${sessionScope[sessionUser].theme}.gif" buttonCssStyle="width:125px" disabled="${requestScope[issueClosed]}">
                cleanAndOpenCloseIssueForm("${requestScope[issue].alias}", "${param.issue}");
            </iwebmvc:button>
        </iwebmvc:panel>
        <div class="panelSeparator"></div>
    </c:if>
    <c:if test="${requestScope[isAdministrator]}">
        <iwebmvc:panel title="ui.issue.actions.administrator" width="98%;margin:0">
            <iwebmvc:button buttonId="${requestScope[issue].alias}TargetVersion" label="ui.issue.actions.administrator.target" buttonIcon="/resource.iwebmvc?file=/images/common/targetversion_${sessionScope[sessionUser].theme}.png" buttonCssStyle="width:125px" disabled="${requestScope[issueClosed]}">
                openTargetVersionForm("${param.issue}", "${requestScope[issue].alias}", "${requestScope[issue].parentProject.alias}");
            </iwebmvc:button>
            <iwebmvc:button buttonId="${requestScope[issue].alias}AssignTo" label="ui.issue.actions.administrator.assignto" buttonIcon="/resource.iwebmvc?file=/images/common/assigned_${sessionScope[sessionUser].theme}.gif" buttonCssStyle="width:125px" disabled="${requestScope[issueClosed]}">
                openPopup('${requestScope[issue].alias}AssignTo');
            </iwebmvc:button>
            <iwebmvc:popup id="${requestScope[issue].alias}AssignTo" title="ui.issue.actions.administrator.assignto" onShow="moveMembershipTree('${requestScope[issue].parentProject.alias}', '${requestScope[issue].alias}');" onHide="moveMembershipTreeBack('${requestScope[issue].parentProject.alias}');">
                <div class="overclear">
                    <div class="float_left" id="${requestScope[issue].alias}MembershipTreeContainer"></div>
                    <div class="float_right">
                        <span id="${requestScope[issue].alias}AssignToLoadingContainer" style="display:none"><img src='<c:url value="resource.iwebmvc?file=images/loading.gif" />' alt='...' /></span>
                        <iwebmvc:button buttonId="${requestScope[issue].alias}AssignToButton" label="ui.issue.actions.administrator.assignto.save" buttonIcon="/resource.iwebmvc?file=/images/common/assigned_${sessionScope[sessionUser].theme}.gif">
                            assignToDeveloper("${requestScope[issue].parentProject.alias}", "${requestScope[issue].alias}", "${iwebmvc:inferDWRConvertedJavascriptClass(issueClass)}", "${iwebmvc:inferDWRConvertedJavascriptClass(userClass)}", "${param.issue}");
                        </iwebmvc:button>
                    </div>
                </div>
            </iwebmvc:popup>
        </iwebmvc:panel>
    </c:if>
</c:if>